<template>
  <div class="sousuojg">
    <div class="sousuo-ipt">
      <img @click="back()" class="back" src="../../assets/img/shouye/header-xinpin/back.png"/>
      <div>
        <img class="sousuo-img" src="../../assets/img/shouye/shouye/sousuo.png"/>
        <input type="text" placeholder="输入商品关键词">
        <img class="chahao-img" @click="del()" src="../../assets/img/shouye/shouye-sousuo/chahao.png"/>
      </div>
      <router-link :to="{name: 'sousuo-jieguo'}">
        <span class="router-span">搜索</span>
      </router-link>
    </div>
    <ul class="sousuojg-rank">
      <li>默认</li>
      <li>价格</li>
      <li>销量</li>
      <li>筛选</li>
    </ul>
    <ul class="sousuojg-goods">
      <li>
        <img src="../../assets/img/shouye/shouye-sousuo/chuncai.png"/>
        <div>
          <h3>
            焕彩璀璨花蕊唇彩4.8g
          </h3>
          <p>焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g</p>
          <h4>
            <img src="../../assets/img/shouye/shouye-sousuo/ribenqi.png"/>
            <img src="../../assets/img/shouye/shouye-sousuo/feiji.png"/>
            <span class="haiwaizhigou">海外直购</span>
            <span class="price">¥166.9</span>
          </h4>
        </div>
      </li>
      <li>
        <img src="../../assets/img/shouye/shouye-sousuo/chuncai.png"/>
        <div>
          <h3>
            焕彩璀璨花蕊唇彩4.8g
          </h3>
          <p>焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g</p>
          <h4>
            <img src="../../assets/img/shouye/shouye-sousuo/ribenqi.png"/>
            <img src="../../assets/img/shouye/shouye-sousuo/feiji.png"/>
            <span class="haiwaizhigou">海外直购</span>
            <span class="price">¥166.9</span>
          </h4>
        </div>
      </li>
      <li>
        <img src="../../assets/img/shouye/shouye-sousuo/chuncai.png"/>
        <div>
          <h3>
            焕彩璀璨花蕊唇彩4.8g
          </h3>
          <p>焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g</p>
          <h4>
            <img src="../../assets/img/shouye/shouye-sousuo/ribenqi.png"/>
            <img src="../../assets/img/shouye/shouye-sousuo/feiji.png"/>
            <span class="haiwaizhigou">海外直购</span>
            <span class="price">¥166.9</span>
          </h4>
        </div>
      </li>
      <li>
        <img src="../../assets/img/shouye/shouye-sousuo/chuncai.png"/>
        <div>
          <h3>
            焕彩璀璨花蕊唇彩4.8g
          </h3>
          <p>焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g焕彩璀璨花蕊唇彩4.8g</p>
          <h4>
            <img src="../../assets/img/shouye/shouye-sousuo/ribenqi.png"/>
            <img src="../../assets/img/shouye/shouye-sousuo/feiji.png"/>
            <span class="haiwaizhigou">海外直购</span>
            <span class="price">¥166.9</span>
          </h4>
        </div>
      </li>
    </ul>
    <div class="up" @click="toTop()" v-if="isUP">
      <img src="../../assets/img/shouye/tuijian-xuanliyanzhuang/toTop.png"/>
    </div>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        isUP: false
      }
    },
    methods: {
      del () {
        document.getElementsByTagName('input')[0].value = '';
      },
      back() {
        this.$router.go(-1);
      },
      toTop () {
        if(document.documentElement){
          document.documentElement.scrollTop = 0;
        }else{
          document.body.scrollTop = 0;
        }
      },
      menu() {
        this.scroll = document.documentElement.scrollTop || document.body.scrollTop;
        if(this.scroll > 0){
          //显示 a 标签
          this.isUP = true;
        }else{
          //隐藏 a 标签
          this.isUP = false;
        }
      },
      top () {
        window.scrollTo(0,0)
      }
    },
    mounted() {
      window.addEventListener('scroll', this.menu)
    },
    created () {
      this.top();
    }
  }
</script>
<style scoped>
  .sousuojg {
    background: #f2f2f2;
    width: 100%;
    padding-top: 2rem;
    position: relative;
  }
  .back {
    vertical-align: middle;
    width: 0.6rem;
    height: 1rem;
    margin: 0.6rem 0.5rem 0 0.5rem;
  }
  .sousuojg .sousuojg-rank {
    background: #fff;
    display: flex;
    border-bottom: 1px solid #ccc;
  }
  .sousuojg .sousuojg-rank li {
    text-align: center;
    flex: 1;
    font-family: MicrosoftYaHei;
    font-size: 0.8rem;
    font-weight: normal;
    font-stretch: normal;
    line-height: 1rem;
    letter-spacing: 0rem;
    margin: 0.2rem;
  }
  .sousuojg .sousuo-ipt{
    height: 2rem;
    background: #e53e42;
    display: flex;
    text-align: center;
    line-height: 2rem;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
  }
  .sousuojg .sousuo-ipt .router-span {
    font-size: 0.8rem;
    padding: 0 0.5rem;
    color: white;
  }
  .sousuojg .sousuo-ipt input {
    width: 10rem;
    height: 1rem;
    background-color: #ffffff;
    border-radius: 0.3rem;
    margin-top: 0.4rem;
    margin-left: 0.5rem;
    padding-left: 0.9rem;
  }
  .sousuojg .sousuo-ipt input::placeholder{
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    color: #e83d41;
  }
  .sousuyojg .sousuo-ipt div{
    position: relative;
    width: 10rem;
    height: 1rem;
  }
  .sousuo-ipt .sousuo-img {
    width: 0.7rem;
    height: 0.7rem;
    position: absolute;
    top: 0.8rem;
    left: 2.2rem;
  }
  .sousuo-ipt .chahao-img {
    width: 0.7rem;
    height: 0.7rem;
    position: absolute;
    top: 0.8rem;
    right: 3.3rem;
  }
  .sousuojg-goods li {
    background: #fff;
    display: flex;
    padding: 0.5rem;
    border-bottom: 1px solid #ccc;
    margin-bottom: 0.5rem;
  }
  .sousuojg-goods li>img{
    height: 4rem;
    margin-left: 0.5rem;
  }
  .sousuojg-goods li>div{
    margin-left: 1rem;
  }
  .sousuojg-goods li h3 {
    font-family: SimHei;
    font-size: 0.7rem;
    font-weight: normal;
    font-stretch: normal;
    color: #333333;
    margin-top: 0.1rem;
  }
  .sousuojg-goods li p {
    margin-top: 0.2rem;
    font-family: SimHei;
    font-size: 0.5rem;
    font-weight: normal;
    font-stretch: normal;
    color: #4d4d4d;
  }
  .sousuojg-goods li h4 img {
    width: 0.9rem;
  }
  .sousuojg .haiwaizhigou {
    font-family: SimHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    color: #666666;
  }
  .sousuojg .price {
    margin-left: 4rem;
    font-family: SimHei;
    font-size: 0.7rem;
    font-weight: normal;
    font-stretch: normal;
    color: #e53e42;
  }
  .up {
    width: 1.5rem;
    position: fixed;
    bottom: 0;
    right: 0.3rem;
  }
  .up img {
    width: 100%;
  }
</style>
